package com.pureut.storage.service.impl;

import com.pureut.storage.domain.SysMaterialCoding;
import com.pureut.storage.mapper.StorageMaterialCodingMapper;
import com.pureut.storage.service.StorageMaterialCodingService;
import com.pureut.storage.vo.SysMaterialCodingMqVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * 物料类别实现层
 */
@RequiredArgsConstructor
@Service
public class StorageMaterialCodingServiceImpl implements StorageMaterialCodingService {

    private final StorageMaterialCodingMapper storageMaterialCodingMapper;

    /**
     * 新增
     *
     * @param mq
     */
    @Override
    public void insertMaterialCoding(SysMaterialCodingMqVo mq) {
        if (mq.getCodingCode() != null) {
            SysMaterialCoding sysMaterialCoding = new SysMaterialCoding();
            BeanUtils.copyProperties(mq, sysMaterialCoding);
            sysMaterialCoding.setCodingId(mq.getCodingId());
            storageMaterialCodingMapper.insertData(sysMaterialCoding);
        }
    }

    /**
     * 修改
     *
     * @param mq
     */
    @Override
    public void updateMaterialCoding(SysMaterialCodingMqVo mq) {
        storageMaterialCodingMapper.updateData(mq);
    }

    /**
     * 删除
     *
     * @param mq
     */
    @Override
    public void deleteMaterialCoding(SysMaterialCodingMqVo mq) {
        storageMaterialCodingMapper.deleteData(Long.parseLong(mq.getIdStr()));
    }
}
